Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not update sidebar for active report drafts #5317

Merged
merged 6 commits into from
Oct 22, 2021

Conversation

meetmangukiya
Copy link
Contributor

Details

Add shouldComponentUpdate method to limit re-renders to cases where draft comment changes were made to reports other than the active report.

Fixed Issues

$ #5166

Tests

For wide width screens

  1. Open a report, start writing something. The reports shouldn't prioritize.
  2. Switch to another report, the previous report with the draft comment should prioritize.
  3. Switch back to the report with draft comment, remove the comment, the report should not de-prioritize.
  4. Switch to another report, the previous report should de-prioritize and the pencil icon should also be removed.
  5. Open a new tab where you create a draft comment on another report, the reports should prioritize on the first tab.

For small screen widths

  1. Reports with draft comments should always prioritize and de-prioritize as it should.

QA Steps

For wide width screens

  1. Open a report, start writing something. The reports shouldn't prioritize.
  2. Switch to another report, the previous report with the draft comment should prioritize.
  3. Switch back to the report with draft comment, remove the comment, the report should not de-prioritize.
  4. Switch to another report, the previous report should de-prioritize and the pencil icon should also be removed.
  5. Open a new tab where you create a draft comment on another report, the reports should prioritize on the first tab.

For small screen widths

  1. Reports with draft comments should always prioritize and de-prioritize as it should.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen.Recording.2021-09-17.at.12.55.52.PM.mov

Mobile Web

Simulator.Screen.Recording.-.iPhone.12.-.2021-09-17.at.13.14.44.mp4

Desktop

Screen.Recording.2021-09-17.at.12.59.20.PM.mov

iOS

Simulator.Screen.Recording.-.iPhone.12.-.2021-09-17.at.13.08.31.mp4

Android

Need help testing android, don't have a working local environment for android. Thanks!

@meetmangukiya meetmangukiya requested a review from a team as a code owner September 17, 2021 07:46
@MelvinBot MelvinBot requested review from mountiny and removed request for a team September 17, 2021 07:46
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had one little change for the comment. Otherwise the ocde looks great! You have done a great job, thank you. 🎉

We will wait with merging this after the n6 release just to avoid any problems. Tahnk you for understanding.

src/pages/home/sidebar/SidebarLinks.js Outdated Show resolved Hide resolved
@mountiny mountiny self-requested a review September 20, 2021 16:15
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, meant to request changes.

Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
@mountiny mountiny self-requested a review September 20, 2021 16:24
@mountiny mountiny changed the title fix: do not update sidebar for active report drafts [HOLD] fix: do not update sidebar for active report drafts Sep 20, 2021
@mountiny
Copy link
Contributor

@meetmangukiya Thanks you very much 🙏 Putting this on hold for the time being.

@parasharrajat
Copy link
Member

parasharrajat commented Oct 7, 2021

Hmm. I think there is an issue with this PR. @meetmangukiya

Issue: When you type the draft message. LHN will not show the draft Icon until you go to another chat and vice-versa(if you clear the draft, the icon will not be removed until to move to another chat) Currently(staging app) behavior is the exact opposite of what I told you and icon should update as soon as the draft is saved or removed.

cc: @mountiny.

@mountiny
Copy link
Contributor

mountiny commented Oct 8, 2021

@parasharrajat Thank you for having a look into this. I am not sure if I understand the problem here, I think that is the behaviour we want (to be different than in staging), essentially we do not want to make any ui changes to LHN while user is typing (on web or desktop where you can see LHN). Therefore we will add the pencil icon or reshuffle the LHN once user switches reports as I do not need to know I have a draft report in the report I just type.

Have you meant some other problem? Sorry if I have misunderstood your comment 😅

@parasharrajat
Copy link
Member

parasharrajat commented Oct 8, 2021

@mountiny
I expect the pencil icon to go away as soon as we clear the draft even if that report is active.

Why?
lets you are chatting with someone and the draft icon will stay forever until to go to another chat.

What I understood from the issue description is that we want to block the shuffle until we switch the chat. (but title says different story).

So IMO, a solution should

  1. Block the shuffle until the user switches the chat which is the reason we created this issue.LHN - Display chats with an existing draft under pinned chats in LHN  #4615 (comment)
  2. Pencil icon should react based on the draft state.

Let me know if this makes sense.

@mountiny
Copy link
Contributor

mountiny commented Oct 8, 2021

@parasharrajat I see. I agree it would be good to make the pencil icon disappear when the draft is deleted (or message sent) and not wait for reports switch.

But coming from the original problem which @mallenexpensify thought, I think the main idea is to not change anything in UI while person is composing the message. The problem now is that as you pause for a bit when typing, the LHN changes and icon is add and it is very eye-catching and you feel like you got a new message while this change is actually also not so important.

Therefore I would say we should not add the pencil icon when we are starting the draft as well, so it is not distracting (it is how it works in Signal for example). We could think of adding functionality to remove the icon when the draft is deleted, but I dont think this is so important now.

I believe we could go with this change and over time evaluate if we want to change the behaviour again to improve it.

What do you think @mallenexpensify?

@meetmangukiya
Copy link
Contributor Author

Yes, I am with @mountiny, we did not want any visual feedback if draft comment changed is for current report to avoid it from being a distraction.

@parasharrajat
Copy link
Member

parasharrajat commented Oct 8, 2021

So yeah, if we allow the pencil to be removed when the draft is cleared that should be enough.

I would say do the above change in this PR as this is currently working on Staging and with this PR we will overwrite that change and break it.

At last, it's your call.


Apart from this, I will still do a test to make sure things are working as they should.

@mountiny
Copy link
Contributor

mountiny commented Oct 8, 2021

@parasharrajat I get your point here and I am open to making the change here if it would be easy update.

@meetmangukiya Would you be able to look into this (ie. when user has draft with icon shown and they delete the message, do NOT change the LHN order but only hide the pencil icon). Otherwise the behaviour should be the same. I would guess it will be minor update, but apologies if I am wrong. Thank you very much for your time.

@meetmangukiya
Copy link
Contributor Author

I think it wouldn't be a simple implementation. Currently, we are achieving this by using shouldComponentUpdate to limit the renders. However, if we want to re-render(to show pencil). We'd have to manage it inside the render function

const {recentReports} = getSidebarOptions(
this.props.reports,
this.props.personalDetails,
this.props.draftComments,
activeReportID,
this.props.priorityMode,
this.props.betas,
);

The pencil is conditional on .hasDraftComment which should be accurate and already be set accordingly. However, to achieve this we'd have to keep track of previous order and then re-order the ordered recentReports back to the order that we previously had.

If we had to do this, I suppose we can do something like:

  1. Store lastRecentReports in some internal class variable for having previous order on re-render
  2. Store another class variable to indicate if this update was only to active report draft comment onlyActiveReportDraftUpdated
  3. if onlyActiveReportDraftUpdated then re-order the newly returned recentReports the same as previous order by using the lastRecentReports' order. If not, we continue as normal, no re-ordering already ordered result.

Although this isn't a particularly good solution. Can think about more if we do decide this is what we want to do.

@mallenexpensify
Copy link
Contributor

not change anything in UI while person is composing the message.
This is the main thing I am hoping to resolve with this. I still find it distracting when anything changes in the LHN while I'm typing a message, I always think there's a new incoming message when there isn't - this can be the shuffling of the order or the pencil icon being added/removed (currently it appears the pencil icon is being added at the same time as the shuffle)

parasharrajat
parasharrajat previously approved these changes Oct 10, 2021
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Now it seems to me that the change I requested is a low priority and After analysis, I can say that it requires a complex solution.

We can skip that for now. I tested other features of the app(IOU, incoming messages, etc) and LHN is reacting to all that so I would say the solution is good.

@mountiny
Copy link
Contributor

Thank you @meetmangukiya and @parasharrajat for looking into this. I agree and I would say the best approach now is to just go ahead and we can always create a new issue in future to tweak the behaviour based on how it goes. Once the N6 hold is off, I will merge this!

@mallenexpensify thank you for your 2 cents here as well 🙇

@mountiny mountiny self-requested a review October 19, 2021 11:29
@mountiny mountiny changed the title [HOLD] fix: do not update sidebar for active report drafts fix: do not update sidebar for active report drafts Oct 19, 2021
@mountiny
Copy link
Contributor

Hi @meetmangukiya, the n6-hold was lifted so we can go ahead with this one.

As this PR is a bit bigger, I would prefer if we could always merge main branch to any of the n6-hold PRs and re-test. I doubt there will be any regression here, but better safe than sorry in case some of the logic was changed without creating merge conflicts.

During the N6 rush, we have merged a lot of small (and some bigger) polish PRs internally and externally, so it is possible there will be some regressions and better to catch it now than in staging.

Thank you for understanding! This wont take long hopefully.

@mountiny mountiny removed the n6-hold label Oct 19, 2021
@meetmangukiya
Copy link
Contributor Author

Web

Screen.Recording.2021-10-21.at.9.37.03.AM.mov

Desktop

Screen.Recording.2021-10-21.at.9.40.15.AM.mov

@meetmangukiya
Copy link
Contributor Author

@mountiny any idea why the CI is failing?

@mountiny
Copy link
Contributor

@meetmangukiya Thank you very much for merging that! It must be related to Rory's post here. There is some problem with Gemfile, so we have to wait for that to be fixed. But once the tests pass, I will merge this!

Thank you very much for your hard and great work on this one!

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meetmangukiya Actually, reading over it, I feel like one little comment about why we do this would be helpful for anyone coming to this later. Feel free to tweak the comment, if you think it can be clearer.

src/pages/home/sidebar/SidebarLinks.js Show resolved Hide resolved
mountiny
mountiny previously approved these changes Oct 21, 2021
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Let's hope the tests will be fixed soon, thank you!

@mountiny
Copy link
Contributor

@meetmangukiya Sorry to ask again, but can you please merge main again? It should fix the tests, hopefully!

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mountiny mountiny merged commit 886aa24 into Expensify:main Oct 22, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @mountiny in version: 1.1.8-10 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.1.10-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants